package com.clothing.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

/**
 * @ClassName: Comment
 * @Description: TODO(Entity-评论)
 * @author Charles.Tao
 * @date 2017年9月4日 下午5:04:02
 * @version 1.0
 */
@Entity
@Table(name = "comment")
public class Comment extends BaseEntity
{
    /**
     * @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么)
     */
    private static final long serialVersionUID = 7664041326645362667L;

    private Article article;

    private String content;

    private User creator;

    private List<CommentReply> commentReplies = new ArrayList<CommentReply>();

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "article", nullable = false)
    public Article getArticle()
    {
        return article;
    }

    public void setArticle(Article article)
    {
        this.article = article;
    }

    @Column(name = "content", nullable = false)
    public String getContent()
    {
        return content;
    }

    public void setContent(String content)
    {
        this.content = content;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "creator", nullable = false)
    public User getCreator()
    {
        return creator;
    }

    public void setCreator(User creator)
    {
        this.creator = creator;
    }

    @OneToMany(mappedBy = "comment", fetch = FetchType.LAZY)
    @OrderBy("createDate asc")
    public List<CommentReply> getCommentReplies()
    {
        return this.commentReplies;
    }

    public void setCommentReplies(List<CommentReply> commentReplies)
    {
        this.commentReplies = commentReplies;
    }
}
